
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/physics/mechanics/examples/rollingdisc_example_kane.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:29:31 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>A rolling disc, with Kane’s method &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
    <script src="../../../../_static/jquery.js"></script>
    <script src="../../../../_static/underscore.js"></script>
    <script src="../../../../_static/doctools.js"></script>
    <script src="../../../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../../../live.sympy.org/static/live-sphinx.js"></script>
    
    <link rel="shortcut icon" href="../../../../_static/sympy-notailtext-favicon.ico"/>
    <link href="rollingdisc_example_kane.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />
    <link rel="next" title="A rolling disc, with Kane’s method and constraint forces" href="rollingdisc_example_kane_constraints.html" />
    <link rel="prev" title="A rolling disc" href="rollingdisc_example.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="rollingdisc_example_kane_constraints.html" title="A rolling disc, with Kane’s method and constraint forces"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="rollingdisc_example.html" title="A rolling disc"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../index.html" >Physics</a> &#187;</li>
          <li class="nav-item nav-item-3"><a href="../index.html" >Classical Mechanics</a> &#187;</li>
          <li class="nav-item nav-item-4"><a href="../examples.html" >Examples for Physics/Mechanics</a> &#187;</li>
          <li class="nav-item nav-item-5"><a href="rollingdisc_example.html" accesskey="U">A rolling disc</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">A rolling disc, with Kane’s method</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="a-rolling-disc-with-kane-s-method">
<h1>A rolling disc, with Kane’s method<a class="headerlink" href="#a-rolling-disc-with-kane-s-method" title="Permalink to this headline">¶</a></h1>
<p>Here the definition of the rolling disc’s kinematics is formed from the contact
point up, removing the need to introduce generalized speeds. Only 3
configuration and three speed variables are need to describe this system, along
with the disc’s mass and radius, and the local gravity (note that mass will
drop out).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy</span> <span class="kn">import</span> <span class="n">symbols</span><span class="p">,</span> <span class="n">sin</span><span class="p">,</span> <span class="n">cos</span><span class="p">,</span> <span class="n">tan</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.mechanics</span> <span class="kn">import</span> <span class="o">*</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">q1</span><span class="p">,</span> <span class="n">q2</span><span class="p">,</span> <span class="n">q3</span><span class="p">,</span> <span class="n">u1</span><span class="p">,</span> <span class="n">u2</span><span class="p">,</span> <span class="n">u3</span>  <span class="o">=</span> <span class="n">dynamicsymbols</span><span class="p">(</span><span class="s1">&#39;q1 q2 q3 u1 u2 u3&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">q1d</span><span class="p">,</span> <span class="n">q2d</span><span class="p">,</span> <span class="n">q3d</span><span class="p">,</span> <span class="n">u1d</span><span class="p">,</span> <span class="n">u2d</span><span class="p">,</span> <span class="n">u3d</span> <span class="o">=</span> <span class="n">dynamicsymbols</span><span class="p">(</span><span class="s1">&#39;q1 q2 q3 u1 u2 u3&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">r</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">g</span> <span class="o">=</span> <span class="n">symbols</span><span class="p">(</span><span class="s1">&#39;r m g&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mechanics_printing</span><span class="p">(</span><span class="n">pretty_print</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</pre></div>
</div>
<p>The kinematics are formed by a series of simple rotations. Each simple rotation
creates a new frame, and the next rotation is defined by the new frame’s basis
vectors. This example uses a 3-1-2 series of rotations, or Z, X, Y series of
rotations. Angular velocity for this is defined using the second frame’s basis
(the lean frame); it is for this reason that we defined intermediate frames,
rather than using a body-three orientation.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">N</span> <span class="o">=</span> <span class="n">ReferenceFrame</span><span class="p">(</span><span class="s1">&#39;N&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Y</span> <span class="o">=</span> <span class="n">N</span><span class="o">.</span><span class="n">orientnew</span><span class="p">(</span><span class="s1">&#39;Y&#39;</span><span class="p">,</span> <span class="s1">&#39;Axis&#39;</span><span class="p">,</span> <span class="p">[</span><span class="n">q1</span><span class="p">,</span> <span class="n">N</span><span class="o">.</span><span class="n">z</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">L</span> <span class="o">=</span> <span class="n">Y</span><span class="o">.</span><span class="n">orientnew</span><span class="p">(</span><span class="s1">&#39;L&#39;</span><span class="p">,</span> <span class="s1">&#39;Axis&#39;</span><span class="p">,</span> <span class="p">[</span><span class="n">q2</span><span class="p">,</span> <span class="n">Y</span><span class="o">.</span><span class="n">x</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span> <span class="o">=</span> <span class="n">L</span><span class="o">.</span><span class="n">orientnew</span><span class="p">(</span><span class="s1">&#39;R&#39;</span><span class="p">,</span> <span class="s1">&#39;Axis&#39;</span><span class="p">,</span> <span class="p">[</span><span class="n">q3</span><span class="p">,</span> <span class="n">L</span><span class="o">.</span><span class="n">y</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">w_R_N_qd</span> <span class="o">=</span> <span class="n">R</span><span class="o">.</span><span class="n">ang_vel_in</span><span class="p">(</span><span class="n">N</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">R</span><span class="o">.</span><span class="n">set_ang_vel</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">u1</span> <span class="o">*</span> <span class="n">L</span><span class="o">.</span><span class="n">x</span> <span class="o">+</span> <span class="n">u2</span> <span class="o">*</span> <span class="n">L</span><span class="o">.</span><span class="n">y</span> <span class="o">+</span> <span class="n">u3</span> <span class="o">*</span> <span class="n">L</span><span class="o">.</span><span class="n">z</span><span class="p">)</span>
</pre></div>
</div>
<p>This is the translational kinematics. We create a point with no velocity
in N; this is the contact point between the disc and ground. Next we form
the position vector from the contact point to the disc’s center of mass.
Finally we form the velocity and acceleration of the disc.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">C</span> <span class="o">=</span> <span class="n">Point</span><span class="p">(</span><span class="s1">&#39;C&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">C</span><span class="o">.</span><span class="n">set_vel</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Dmc</span> <span class="o">=</span> <span class="n">C</span><span class="o">.</span><span class="n">locatenew</span><span class="p">(</span><span class="s1">&#39;Dmc&#39;</span><span class="p">,</span> <span class="n">r</span> <span class="o">*</span> <span class="n">L</span><span class="o">.</span><span class="n">z</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Dmc</span><span class="o">.</span><span class="n">v2pt_theory</span><span class="p">(</span><span class="n">C</span><span class="p">,</span> <span class="n">N</span><span class="p">,</span> <span class="n">R</span><span class="p">)</span>
<span class="go">r*u2*L.x - r*u1*L.y</span>
</pre></div>
</div>
<p>This is a simple way to form the inertia dyadic. The inertia of the disc does
not change within the lean frame as the disc rolls; this will make for simpler
equations in the end.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">I</span> <span class="o">=</span> <span class="n">inertia</span><span class="p">(</span><span class="n">L</span><span class="p">,</span> <span class="n">m</span> <span class="o">/</span> <span class="mi">4</span> <span class="o">*</span> <span class="n">r</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">m</span> <span class="o">/</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">r</span><span class="o">**</span><span class="mi">2</span><span class="p">,</span> <span class="n">m</span> <span class="o">/</span> <span class="mi">4</span> <span class="o">*</span> <span class="n">r</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mprint</span><span class="p">(</span><span class="n">I</span><span class="p">)</span>
<span class="go">m*r**2/4*(L.x|L.x) + m*r**2/2*(L.y|L.y) + m*r**2/4*(L.z|L.z)</span>
</pre></div>
</div>
<p>Kinematic differential equations; how the generalized coordinate time
derivatives relate to generalized speeds.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">kd</span> <span class="o">=</span> <span class="p">[</span><span class="n">dot</span><span class="p">(</span><span class="n">R</span><span class="o">.</span><span class="n">ang_vel_in</span><span class="p">(</span><span class="n">N</span><span class="p">)</span> <span class="o">-</span> <span class="n">w_R_N_qd</span><span class="p">,</span> <span class="n">uv</span><span class="p">)</span> <span class="k">for</span> <span class="n">uv</span> <span class="ow">in</span> <span class="n">L</span><span class="p">]</span>
</pre></div>
</div>
<p>Creation of the force list; it is the gravitational force at the center of mass of
the disc. Then we create the disc by assigning a Point to the center of mass
attribute, a ReferenceFrame to the frame attribute, and mass and inertia. Then
we form the body list.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ForceList</span> <span class="o">=</span> <span class="p">[(</span><span class="n">Dmc</span><span class="p">,</span> <span class="o">-</span> <span class="n">m</span> <span class="o">*</span> <span class="n">g</span> <span class="o">*</span> <span class="n">Y</span><span class="o">.</span><span class="n">z</span><span class="p">)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">BodyD</span> <span class="o">=</span> <span class="n">RigidBody</span><span class="p">(</span><span class="s1">&#39;BodyD&#39;</span><span class="p">,</span> <span class="n">Dmc</span><span class="p">,</span> <span class="n">R</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="p">(</span><span class="n">I</span><span class="p">,</span> <span class="n">Dmc</span><span class="p">))</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">BodyList</span> <span class="o">=</span> <span class="p">[</span><span class="n">BodyD</span><span class="p">]</span>
</pre></div>
</div>
<p>Finally we form the equations of motion, using the same steps we did before.
Specify inertial frame, supply generalized coordinates and speeds, supply
kinematic differential equation dictionary, compute Fr from the force list and
Fr* from the body list, compute the mass matrix and forcing terms, then solve
for the u dots (time derivatives of the generalized speeds).</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">KM</span> <span class="o">=</span> <span class="n">KanesMethod</span><span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">q_ind</span><span class="o">=</span><span class="p">[</span><span class="n">q1</span><span class="p">,</span> <span class="n">q2</span><span class="p">,</span> <span class="n">q3</span><span class="p">],</span> <span class="n">u_ind</span><span class="o">=</span><span class="p">[</span><span class="n">u1</span><span class="p">,</span> <span class="n">u2</span><span class="p">,</span> <span class="n">u3</span><span class="p">],</span> <span class="n">kd_eqs</span><span class="o">=</span><span class="n">kd</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">(</span><span class="n">fr</span><span class="p">,</span> <span class="n">frstar</span><span class="p">)</span> <span class="o">=</span> <span class="n">KM</span><span class="o">.</span><span class="n">kanes_equations</span><span class="p">(</span><span class="n">BodyList</span><span class="p">,</span> <span class="n">ForceList</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">MM</span> <span class="o">=</span> <span class="n">KM</span><span class="o">.</span><span class="n">mass_matrix</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">forcing</span> <span class="o">=</span> <span class="n">KM</span><span class="o">.</span><span class="n">forcing</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">rhs</span> <span class="o">=</span> <span class="n">MM</span><span class="o">.</span><span class="n">inv</span><span class="p">()</span> <span class="o">*</span> <span class="n">forcing</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">kdd</span> <span class="o">=</span> <span class="n">KM</span><span class="o">.</span><span class="n">kindiffdict</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">rhs</span> <span class="o">=</span> <span class="n">rhs</span><span class="o">.</span><span class="n">subs</span><span class="p">(</span><span class="n">kdd</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">rhs</span><span class="o">.</span><span class="n">simplify</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mprint</span><span class="p">(</span><span class="n">rhs</span><span class="p">)</span>
<span class="go">Matrix([</span>
<span class="go">[(4*g*sin(q2) + 6*r*u2*u3 - r*u3**2*tan(q2))/(5*r)],</span>
<span class="go">[                                       -2*u1*u3/3],</span>
<span class="go">[                          (-2*u2 + u3*tan(q2))*u1]])</span>
</pre></div>
</div>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../../../index.html">
              <img class="logo" src="../../../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h4>Previous topic</h4>
  <p class="topless"><a href="rollingdisc_example.html"
                        title="previous chapter">A rolling disc</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="rollingdisc_example_kane_constraints.html"
                        title="next chapter">A rolling disc, with Kane’s method and constraint forces</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../../_sources/modules/physics/mechanics/examples/rollingdisc_example_kane.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="rollingdisc_example_kane_constraints.html" title="A rolling disc, with Kane’s method and constraint forces"
             >next</a> |</li>
        <li class="right" >
          <a href="rollingdisc_example.html" title="A rolling disc"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../index.html" >Physics</a> &#187;</li>
          <li class="nav-item nav-item-3"><a href="../index.html" >Classical Mechanics</a> &#187;</li>
          <li class="nav-item nav-item-4"><a href="../examples.html" >Examples for Physics/Mechanics</a> &#187;</li>
          <li class="nav-item nav-item-5"><a href="rollingdisc_example.html" >A rolling disc</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">A rolling disc, with Kane’s method</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/physics/mechanics/examples/rollingdisc_example_kane.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:29:31 GMT -->
</html>